home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Gold Collection
/
Software Vault - The Gold Collection (American Databankers) (1993).ISO
/
cdr47
/
wasm223.zip
/
CRC_TC.ASM
< prev
next >
Wrap
Assembly Source File
|
1993-05-04
|
1KB
|
36 lines
;================================================
; CRC Generation Subroutine for Turbo C
;
; This is a code fragment to update a 16 bit CRC
; value by one byte. To use in Turbo C, perform
; the following steps:
;
; WASM crc_tc
; CONVERT c < crc_tc.com > temp
; DEL crc_tc.com
;
; Now the machine code is in text format in the
; file TEMP. Use this code as follows:
;
; void far CRC16 (unsigned int far *crc, char data)
; {
; __emit__ (
; { insert the contents of file TEMP here }
; )
; }
CRCGEN EQU 1021H ;xmodem CRC bit pattern
push ds ;DS must be saved
mov al, [bp+10] ;load data byte
lds bx, [bp+6] ;load address of CRC value
mov dx, [bx] ;load current CRC value
mov cx, 8 ;bits to process
a1 shl al ;shift bit into carry
rcl dx ;roll into checksum
jnc a2 ;skip xor if bit not shifted out
xor dx, CRCGEN ;xor CRC value
a2 loop a1 ;loop for each bit in byte
mov [bx], dx ;save CRC value
pop ds ;restore DS